package com.thecafetechno.main;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.Transaction;

import com.thecafetechno.university.Student;
import com.thecafetechno.util.HibernateUtil;

public class DataSelectionHQLExample {
	public static void main(String[] ar) {
		DataPopulator.populateData();
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		Transaction transaction = session.beginTransaction();
		// .list() method executes the Query instance
		List<Student> studentList = session.createQuery("from Student").list();
		transaction.commit();
		for (Student student : studentList) {
			System.out.println(student);
		}
	}
}
